<?php
/**
 * Created by PhpStorm.
 * User: zhu
 * Date: 2016/10/7
 * Time: 15:47
 */

namespace Forxx\Api;


use Forxx\Dao\AskBaseTable;

class Mapping {

    /**
     * @param $val
     * @param string $default
     * @param array $replace
     * @return string
     */
    public static function getNameOfAskState($val,$default = '未知',$replace = [])
    {
        $val = intval($val);
        if(isset($replace[$val]))
        {
            return $replace[$val];
        }
        $list = self::getAllAskStates();
        if(isset($list[$val]))
        {
            return $list[$val];
        }
        return $default;
    }

    /**
     * @return array
     */
    public static function getAllAskStates()
    {
        return [
            AskBaseTable::STATE_NOT_RESOLVE => '待解决',
            AskBaseTable::STATE_ANSWER => '待处理',
            AskBaseTable::STATE_RESOLVED => '已解决',
            AskBaseTable::STATE_EXPIRED => '已过期',
        ];
    }
}